package codeanticode.vision;

import processing.core.PApplet;
import com.googlecode.javacv.FrameRecorder;
import com.googlecode.javacv.OpenCVFrameRecorder;

public class MovieRecorder {
  protected Vision vision;
  protected FrameRecorder recorder;
  
  public MovieRecorder(PApplet parent, String filename, int width, int height) {
    vision = new Vision(parent);
    recorder = new OpenCVFrameRecorder(parent.dataPath(filename), width, height);  
  }
  
  public void start() {
    try { 
      recorder.start();
    } catch (Exception e) {      
    }    
  }
  
  public void stop() {
    try { 
      recorder.stop();
    } catch (Exception e) {      
    }    
  }  
  
  public void record(BaseGrabber grabber) {
    try {      
      recorder.record(grabber.grabImage);
    } catch (Exception e) {
    }    
  }
}
